import axios from "axios";
import React, {useEffect, useState} from 'react';
import {Button, List} from 'antd';
import "./CreateList.css"
import {Link, useNavigate} from 'react-router-dom';
import config from '../utils/config'

function CreateList() {
    const [campingList, setCampingList] = useState([]);
    const navigate = useNavigate();

    useEffect(() => {
        axios.get(`${config.serverDomain}/admin/camping/review/create`)
            .then(res => setCampingList(res.data))
            .catch(res => window.alert("系统错误"))
    }, [])

    return <div>
        <h1>新营地申请列表</h1>
        <List
            dataSource={campingList}
            renderItem={(camping) => (
                <List.Item>
                    {camping.name}
                    <Link to={`/camping/create/${camping.id}`}>
                        <Button type="primary" shape="round" className="operate-btn">查看</Button>
                    </Link>
                </List.Item>
            )}/>
    </div>
}

export default CreateList;
